package com.cskaoyan.controller.admin;

import com.cskaoyan.bean.MarketAd;
import com.cskaoyan.model.admin.bo.BaseParam;
import com.cskaoyan.model.admin.vo.BaseDataListVo;
import com.cskaoyan.model.admin.vo.BaseRespVo;
import com.cskaoyan.service.admin.AdminAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hanshuai
 * @version 1.0
 * @description @TODO
 * @date 2021/11/30 22:53
 */
@RestController
@RequestMapping("admin/ad")
public class AdminAdController {

    @Autowired
    AdminAdService adminAdService;

    @RequestMapping("/list")
    public BaseRespVo adList(BaseParam baseParam, String content, String name) {
        BaseDataListVo baseDataListVo = adminAdService.adList(baseParam, content, name);
        return BaseRespVo.ok(baseDataListVo);
    }

    @RequestMapping("/create")
    public BaseRespVo adCreate(@RequestBody MarketAd marketAd){
        MarketAd marketAd1=adminAdService.adCreate(marketAd);
        return BaseRespVo.ok(marketAd1);
    }

    @RequestMapping("/update")
    public BaseRespVo adUpdate(@RequestBody MarketAd marketAd){
        MarketAd marketAd1=adminAdService.adUpdate(marketAd);
        return BaseRespVo.ok(marketAd1);
    }

    @RequestMapping("/delete")
    public BaseRespVo adDelete(@RequestBody MarketAd marketAd){
        adminAdService.adDelete(marketAd);
        return BaseRespVo.ok(null);
    }
}
